﻿using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Assist;
using YArchitech.Controls;

namespace YJKRevitPipeSetting.Forms
{
	internal class HYintComBox : Assist.YJKComboBox
	{
		protected override void OnKeyUp(KeyEventArgs e)
		{
			if (e.Modifiers == Keys.Tab)
			{
				return;
			}
			string text = base.Text;
			int length = text.Length;
			if (!Regex.Match(text, "^\\d*$").Success)
			{
				base.Text = text.Substring(0, length - 1);
				YJKMessageBox.Show("数值为正整数，请重新输入!");
			}
			if (length == 1 && e.KeyValue == 48)
			{
				base.Text = text.Substring(0, length - 1);
				YJKMessageBox.Show("数值为正整数，请重新输入!");
			}
			base.OnKeyUp(e);
		}

		protected override void OnMouseLeave(EventArgs e)
		{
			if (base.Text.Count<char>() == 0)
			{
				YJKMessageBox.Show("不能为空，请重新输入!");
			}
			base.OnMouseLeave(e);
		}
	}
}
